package br.unip.tcc.domotic.orm;

import java.util.HashSet;
import java.util.Set;

import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.PrimaryKeyJoinColumn;
import javax.persistence.Table;

@Entity
@Table(name = "sensor")
@PrimaryKeyJoinColumn(name="cod_dispositivo")
public class Sensor extends Device {
	
	private static final long serialVersionUID = 1L;
	
	private SensorType sensorType;
	private Set<Condition> conditions = new HashSet<Condition>(0);
	
	@ManyToOne(fetch = FetchType.LAZY)
	@JoinColumn(name = "cod_tipo_sensor", nullable = false)
	public SensorType getSensorType() {
		return sensorType;
	}

	public void setSensorType(SensorType sensorType) {
		this.sensorType = sensorType;
	}
	
	@OneToMany(fetch = FetchType.LAZY, mappedBy = "sensor")
	public Set<Condition> getConditions() {
		return conditions;
	}
	
	public void setConditions(Set<Condition> conditions) {
		this.conditions = conditions;
	}
	
}
